package cn.xd.security.token;

import cn.xd.common.enums.IBaseEnum;
import cn.xd.common.enums.auth.AppUserTypeEnum;
import cn.xd.security.command.PasswordWithVerifyLoginCommand;
import lombok.Getter;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;

@Getter
public class AdminUserCaptchaToken extends UsernamePasswordAuthenticationToken {
    private final String verifyKey;
    private final String verifyCode;

    private final String name;

    private final String password;

    private final AppUserTypeEnum type;

    public AdminUserCaptchaToken(PasswordWithVerifyLoginCommand command) {
        super(command.getUsername() + "@" + command.getOrgId(), command.getPassword());
        this.verifyCode = command.getVerifyCode();
        this.verifyKey = command.getVerifyCodeKey();
        this.password = command.getPassword();
        this.name = command.getUsername() + "@" + command.getOrgId();
        this.type = IBaseEnum.getEnumByCode(command.getType(), AppUserTypeEnum.class);
    }
}
